package top.zhaoyuliu.logbook.client.connect.packet;

import cn.hutool.json.JSONUtil;

/**
 * 
 * Copyright © 2021 Arain. All rights reserved.
 *
 * @Title: PacketBuilder.java
 * @Prject: logbook-client
 * @Package: top.zhaoyuliu.logbook.client.connect.packet
 * @Description: <功能详细描述>
 * @author: Arain
 * @date: 2021年1月22日 下午4:05:51
 * @version: V1.0
 */
public class PacketBuilder {
	/**
	 * 消息类型，其值在Type中定义
	 */
	private byte type;

	private Object body;

	public PacketBuilder setType(byte type) {
		this.type = type;
		return this;
	}

	public PacketBuilder setBody(Object body) {
		this.body = body;
		return this;
	}

	public LbPacket build() {
		return new LbPacket(type, JSONUtil.toJsonStr(body).getBytes());
	}
}
